package com.mpp.common.exception;

import com.mpp.common.result.ResultCodeEnum;

/**
 * @author MMDZ
 * @date 2022/8/16 15:27
 * @description TODO 业务异常
 */
public class MyServiceException extends RuntimeException {

    private static final long serialVersionUID = 1L;

    /**
     * 错误码
     */
    private Integer code;

    /**
     * 错误提示
     */
    private String message;

    /**
     * 错误明细，内部调试错误
     */
    private String detailMessage;

    /**
     * 空构造方法，避免反序列化问题
     */
    public MyServiceException() {
    }

    public MyServiceException(String message) {
        this.message = message;
    }

    public MyServiceException(Integer code, String message) {
        this.code = code;
        this.message = message;
    }

    public MyServiceException(ResultCodeEnum resultCodeEnum) {
        this.code = resultCodeEnum.getCode();
        this.message = resultCodeEnum.getMessage();
    }

    public String getDetailMessage() {
        return detailMessage;
    }

    public String getMessage() {
        return message;
    }

    public Integer getCode() {
        return code;
    }

    public MyServiceException setMessage(String message) {
        this.message = message;
        return this;
    }

    public MyServiceException setDetailMessage(String detailMessage) {
        this.detailMessage = detailMessage;
        return this;
    }
}
